var gulp = require('gulp');
var aglio = require('gulp-aglio');
var watch = require('gulp-watch');
var connect = require('gulp-connect');

gulp.task('genDocs', function() {
  gulp.src('./src/**/index.md')
    .pipe(aglio({
      template: './themes/aglio-theme-olio/templates/index.jade',
      locals: {
        variables: 'flatly'
      }
    }))
    .pipe(gulp.dest('./dist'));
});
gulp.task('img', function() {
  gulp.src('./src/**/*.png')
    .pipe(gulp.dest('./dist'));
});
gulp.task('reload', function() {
  connect.reload();
});

gulp.task('watch', function() {
  gulp.watch(['./src/**/*.md'], ['genDocs', 'img', 'reload']);
});

gulp.task('connect', function() {
  connect.server({
    port: 3000,
    root: 'dist',
    livereload: true
  });
});

gulp.task('default', ['genDocs', 'connect', 'watch']);
